package com.ysx.Config;

import com.ysx.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


/**
 * @Description: 指定拦截内容的配置类
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {
    //创建自定义拦截对象
   HandlerInterceptor interceptor = new LoginInterceptor();
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //完成拦截器注册
        registry.addInterceptor(interceptor)
                //过滤的路径
                .addPathPatterns("/admin/**") //表示拦截admin下的所有请求
                .excludePathPatterns("/admin")//放心/admim请求
                .excludePathPatterns("/admin/login");
    }
}